 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import = "model.News"%>
<%@ page import = "control.NewsControl"%>
<%@page import="util.ParamUtil"%>
<%@page import="control.SubColumnControl"%>
<%@page import="util.StringFormat"%>
<%@ include file="../login/login_check.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>动态</title>
  <link href="../../../resources/css/admin/pages_subpage.css" rel="stylesheet" type="text/css"/>
  <script type="text/javascript" src="../../../resources/js/jquery-1.3.2.js"></script>
  <script>
  	$(function(){
				//添加隔行换色
				$("tbody tr:odd").addClass("oddTR");
				
				// 添加鼠标经过样式
				$("tbody tr").mouseover(function(){
					$(this).addClass("mouseOverTR");
					$(this).children("td").each(function(){
						$(this).addClass("mouseOverTD");
						});
				});
					
				
				$("tbody tr").mouseout(function(){
					$(this).removeClass(["mouseOverTR"]);
					$(this).children("td").each(function(){
							$(this).removeClass(["mouseOverTD"]);
						});
					});
			})
			
			function add(){
				window.location.href="http://www.baidu.com";
				return false;
			}
  </script>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
  <form></form>
  <form action="newslist.jsp">
 <table width="1100" border="0" cellspacing="0" cellpadding="0">
  <tr>
  		<th align = center>标题</th>
  		<th align = center>内容简介</th>
  		<th align = center>类别</th>
  		<th align = center>阅读次数</th>
  		<th align = center>发布时间</th>
  		<th align = center>管理</th>
  </tr>
	

 <% 	  
        request.setCharacterEncoding("UTF-8");
        int sid = ParamUtil.getInt(request,"sid",1);
 		int pages = ParamUtil.getInt(request, "pages", 0);
		int rowsPerPage = ParamUtil.getInt(request, "pageSize", 10);
		NewsControl nc = new NewsControl();
		News news = new News();
		List<News> list1 = new ArrayList<News>();
		//list1 = (List) nc.getWorks_2(pages,rowsPerPage,"addtime");
		list1 = (List) nc.getNewsBySubColumn(pages,rowsPerPage,sid);
		System.out.println(list1.size());
			for (int i = 0; i < list1.size(); i++) {
				news = list1.get(i);			
%>
 	<tr>
 		<td align = center><a href ="ReadMe.jsp?id=<%=news.getId()%>"><%=news.getTitle()%></a></td>
 		<td align = center><%if(StringFormat.RemoveFormat(news.getContent()).length()>=20)out.print(StringFormat.RemoveFormat(news.getContent()).substring(0,19)+"...");else{out.print(StringFormat.RemoveFormat(news.getContent()));} %></td>
 		<td align = center><%=SubColumnControl.getSubColumn(news.getSubcolumn()).getSubcolumn()%></td>
 		<td align = center><%=news.getView()%></td>
 		<td align = center><%=news.getAddtime()%></td>
 		<td align = center><a href = "news_update.jsp?id=<%=news.getId()%>">修改</a>|<a href = "news_delete.jsp?id=<%=news.getId()%>">删除</a>
 		<input type="hidden" name="sid" value="<%=sid %>">
 		</td>
 	</tr>	

 		<%
				}%>
				<tr><td align = center colspan="6">
				<%
			out.println(NewsControl.pageInstance.getToolsMenu(pages));
	  %></td></tr>
</table>

 	  
	  </form>
	  <div>
	  <input type = "button" value = "添加动态"
	  	onclick="window.location.href='news_add.jsp?sid=<%=sid %>'" />	
	  	</div>
  </body>
</html>
